
/* Includes ------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "main.h"
#include "uart.h"
#include "common.h"

uint8_t uart_recv_flag = 0;
uint32_t uart_recv_length = 0;
char uart_recv_buf[UART_RECV_BUF_MAXSIZE] = {0};
uint8_t esp_recv_flag = 0;
volatile uint8_t ble_recv_flag = 0;
u8 delay_flag = 0;
u16 delay_cnt = 0;
Time timer = {0};
Flag flag = {0};
LED ledR = {0};
LED ledB = {0};
extern char Ble_send_buf[512];

void NVIC_init(void)
{

    nvic_init(UARTx);
}

void bsp_init()
{
    LL_CMU_EnablePeriphBusClock_GPIO();
    // 串口打印
    gpio_init(UART0);
    uart_init(UART0);

    flash_init();
}
/*
 * @brief  Main program
 * @param  None
 * @retval None
 */
int main(void)
{
    SCB->VTOR = ApplicationAddress; // 修改向量表位置

    bsp_init();                  // 硬件初始化
    NVIC_init();                 // 设置中断源
    printf("version:1.0.2\r\n"); // 版本号 可以查看是否ota成功
    while (1)
    {

        if (uart_recv_flag) // 串口接收指令
        {
            if (strstr(uart_recv_buf, "ota") != NULL) // 识别到ota标志
            {

                SerialDownload(); // 开始ota
            }
        }
    }
}

/************************ (C) COPYRIGHT FMSH Microelectronics *****END OF FILE****/
